package Util;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class JSONUtil {
	public static void obj2Json(HttpServletResponse resp, Object object) throws IOException {
		JSONObject josonObject = JSONObject.fromObject(object);
		resp.setContentType("text/html;charset=utf-8");
		resp.getWriter().write(josonObject.toString());
	}
	public static void arrayJson(HttpServletResponse resp, Object object) throws IOException {
		JSONArray jsonArray = JSONArray.fromObject(object);
		resp.setContentType("text/html;charset=utf-8");
		resp.getWriter().write(jsonArray.toString());
	}
}
